package org.wzy.design.patterns.factory.abstr;

import org.wzy.design.patterns.factory.simple.Car;

/**
 * ClassName: AbstractFactory <br/>
 * Function: TODO ADD FUNCTION. <br/>
 * Reason: TODO ADD REASON(可选). <br/>
 * date: 2017年6月16日 下午1:21:48 <br/>
 * 
 * @author wzy_h
 * @version
 * @since JDK 1.8
 */
public abstract class AbstractFactory {
	
	protected abstract Car getCar();
	
	// 固定模式的委派
	public Car getCar(String name) {
		if ("BMW".equalsIgnoreCase(name)) {
			return new BmwFactory().getCar();
		} else if ("BENZ".equalsIgnoreCase(name)) {
			return new BenzFactory().getCar();
		} else if ("AUDI".equalsIgnoreCase(name)) {
			return new AudiFactory().getCar();
		} else {
			System.out.println("没有这项工艺，产品无法生产。");
		}
		
		return null;
	}
}
